<%-- 
    Document   : AssessmentForm
    Created on : Jan 3, 2012, 9:41:41 PM
    Author     : olivier
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html"  prefix="html" %> 
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<div style="padding:10px;margin:10px;border:1px solid #333">

    <s:form name="form" action="/assessment/create" id="addAssForm">
        <label><b> Assessment Details below :</b> </label>
        <br/>
        <br/>
        <table>
            <tr>
                <td class="tdLabel">
                    Title:
                </td>
                <td>
                    <s:textfield name="ass.title" size="30" readonly="update"/> 

                </td>
                <td>
                    <s:fielderror><s:param>ass.title</s:param></s:fielderror>
                </td>
            </tr>
            <tr>
                <td class="tdLabel">Description:</td>
                <td><s:textfield name="ass.description" size="30"/> 
                </td>
                <td>
                    <s:fielderror><s:param>ass.description</s:param></s:fielderror>
                </td>
            </tr>
            <tr>
                <td class="tdLabel">Maximum Marks:</td>
                <td><s:textfield name="ass.maximumMark" size="40"/> 
                </td>
            </tr>
            <tr>
                <td class="tdLabel">Type of Assessment:</td>
                <td>
                    <s:select name="ass.type" list="{'Exercise','Deliverable'}"/>
                </td>
            </tr>
            <tr>
                <td class="tdLabel">To Range</td>
                <td><s:textfield name="ass.toRange" size="40" value="10"/> 
                    <s:fielderror><s:param>ass.toRange</s:param></s:fielderror></td>
            </tr>
            <tr>
                <td class="tdLabel">From Range</td>
                <td><s:textfield name="ass.fromRange" size="40" value="1"/> 
                    <s:fielderror><s:param>ass.fromRange</s:param></s:fielderror></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td>
                    <br/>
                    <input type="submit" value="Add" />
                    <input type="button" value="Cancel" onclick="$('#addAssessmentContainer').hide('slow')"/>
                </td>
            </tr>
        </table>
    </s:form>
</div>

<script type="text/javascript">
    
    $(function(){
        $("#addAssForm").submit(function(e){
            e.preventDefault();

            dataString = $("#addAssForm").serialize();

            $.ajax({
                type: "POST",
                url: "<s:url value="/assessment/create_%{selectedModuleCode}"/>",
                data: dataString,
                success: function(data) {
                    if (data == 'ok')
                        $('#tabs').tabs( "load" ,1);
                    else
                        $('#addAssessmentContainer').html(data);
                    
                },
                beforeSend: function(data) {
                    $('#addAssessmentContainer').html('<img src="<s:url value="/img/loading.gif"/>" style="padding:10px;" border="0"/>');
            
                }       
                

            });          

        });
    });
    
    
</script>

